--local MyStyle={}
module(...,package.seeall)

function SwipeRefreshLayout(view)
  view.setProgressViewOffset(true,0,64)
  view.setColorSchemeColors({强调色})
  view.setProgressBackgroundColorSchemeColor(背景颜色)
  return view
end
function FloatButton(view)
  Ripple(view,淡色强调波纹)
  view.parent.backgroundColor=背景颜色
  view.parent.elevation=math.dp2int(6)
  if MoreVisualEffect then
    import "Jesse205.FloatButtonAnim"
    local _LastOpen
    view.onTouch=function(view,event)
      local eventX,eventY=event.x,event.y
      local ViewW,ViewH=view.measuredWidth,view.measuredHeight

      if not(_LastOpen) and event.getAction()==MotionEvent.ACTION_DOWN then
        FloatButtonAnim.open(view)
        _LastOpen=true
       elseif _LastOpen and event.getAction()==MotionEvent.ACTION_UP then
        FloatButtonAnim.close(view)
        _LastOpen=false
       elseif _LastOpen and (eventX+10<0 or eventY+10<0 or eventX-10>ViewW or eventY-10>ViewH) then
        FloatButtonAnim.close(view)
        _LastOpen=false
      end
    end
  end

  return view
end

function fillListView(view,card,contrast,onScroll)


  --if tonumber(Build.VERSION.SDK) >23 then
  import "Jesse205.ActionBarAnim"
  local contrast=contrast or "LastActionBarElevation"
  _G[contrast]=工具栏阴影
  view.setOnScrollListener{
    onScroll=function(view,firstVisibleItem,visibleItemCount,totalItemCount)
      if (onScroll==nil or onScroll(view,firstVisibleItem,visibleItemCount,totalItemCount)) and 工具栏阴影==0 and MoreVisualEffect then
        local childView=view.getChildAt(0)
        if childView then
          local top=childView.getTop()
          if top>=0 and firstVisibleItem==0 and _G[contrast]~=0 then
            _G[contrast]=0
            --activity.ActionBar.setElevation(_G[contrast])
            ActionBarAnim.closeElevation(card)
           elseif (top<0 or firstVisibleItem>0) and _G[contrast]==0 then
            _G[contrast]=math.dp2int(4)
            --activity.ActionBar.setElevation(_G[contrast])
            ActionBarAnim.openElevation(card,_G[contrast])
          end
        end
      end
    end}
  --end

  return view
end

function fillScrollView_onScroll(view,card,contrast,onScroll,...)
  if (onScroll==nil or onScroll(view,...)) and 工具栏阴影==0 and MoreVisualEffect then
    local scroll=view.getScrollY()
    --print(scroll)
    if scroll<=0 and _G[contrast]~=0 then
      _G[contrast]=0
      --activity.ActionBar.setElevation(_G[contrast])
      ActionBarAnim.closeElevation(card)
     elseif scroll>0 and _G[contrast]==0 then
      _G[contrast]=math.dp2int(4)
      --activity.ActionBar.setElevation(_G[contrast])
      ActionBarAnim.openElevation(card,_G[contrast])
    end
  end
end

function fillScrollView(view,card,contrast,onScroll)

  local contrast=contrast or "LastActionBarElevation"
  _G[contrast]=工具栏阴影
  view.setOnScrollChangeListener{
    onScrollChange=function(view,...)
      fillScrollView_onScroll(view,card,contrast,onScroll,...)
    end}
  --end
  return view
end
function topCard(view,color)
  local drawable=ButtonFrame(view,nil,nil,color or 背景颜色,{0,0,0,0,math.dp2int(16),math.dp2int(16),math.dp2int(16),math.dp2int(16)})
  return view or drawable
end

--[[
function Button(view)
  view.background.getDrawable(0).getDrawable().setCornerRadius(math.dp2int(4))
  return view
end]]

--return MyStyle